<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
<%@ Import Namespace="System.Drawing"%>

<%@ Import Namespace="System.Web.UI.DataVisualization.Charting"%>
<%@ Import Namespace="C3.Proto.Core.Model"%>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Region Report
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <h2><%=ViewData["Region"] %> - Region Report</h2>
    <a href="/Home">Back</a> <br />
    <%if((string) ViewData["Mode"] != "print"){ %><a href="/Home/Export">Export to Pdf</a><%} %>
    <table cellpadding="5" cellspacing="5" style="border-collapse:collapse" border="1">
        <tr>
            <td>Project Names and Site Number</td>
            <td>Institute</td>
            <td>GC Inspections</td>
            
        </tr>
    <%
        foreach (var p in ((RegionResults)ViewData["RegionResults"]).GCProjects)
        {%>
        <tr>
            <td><%=p.Project %></td>
            <td><%=p.Institute %></td>
            <td><%=p.Inspections %></td>
        </tr>
           
        <%}%>
        
    </table>
    
   <br />
  
    <% var Chart2 = new System.Web.UI.DataVisualization.Charting.Chart
                      {
                          Width = 750,
                          Height = 296,
                          RenderType = RenderType.ImageTag,
                          ImageLocation = "..\\..\\TempImages\\ChartPic_#SEQ(200,30)",
                          Palette = ChartColorPalette.BrightPastel
                      };

       var t = new Title(string.Format("{0} Safety Deficiencies", ViewData["Region"]), Docking.Top, new System.Drawing.Font("Trebuchet MS", 9, System.Drawing.FontStyle.Bold), System.Drawing.Color.FromArgb(26, 59, 105));
   Chart2.Titles.Add(t);
   Chart2.ChartAreas.Add("ChartArea1");

    // Enable X axis labels automatic fitting
   Chart2.ChartAreas["ChartArea1"].AxisX.IsLabelAutoFit = true;
   Chart2.ChartAreas["ChartArea1"].AxisX.TextOrientation = TextOrientation.Rotated90;
    // Set X axis automatic fitting style
   Chart2.ChartAreas["ChartArea1"].AxisX.LabelAutoFitStyle =
        LabelAutoFitStyles.DecreaseFont | LabelAutoFitStyles.IncreaseFont | LabelAutoFitStyles.WordWrap;
    // create a couple of series
   Chart2.Series.Add("GC");
   Chart2.Series.Add("OFPC");
   Chart2.Series.Add("ROCIP");

    
    Chart2.ChartAreas["ChartArea1"].AxisX.IntervalAutoMode = IntervalAutoMode.FixedCount;
    Chart2.ChartAreas["ChartArea1"].AxisX.Interval = 1;





    Chart2.Series["GC"].Points.AddY(((RegionResults)ViewData["RegionResults"]).GCSeverityA);
    Chart2.Series["GC"].IsValueShownAsLabel = false;

    Chart2.Series["OFPC"].Points.AddY(((RegionResults)ViewData["RegionResults"]).OFPCSeverityA);
    Chart2.Series["OFPC"].Points[0].AxisLabel = "A";
    Chart2.Series["OFPC"].IsValueShownAsLabel = false;

    Chart2.Series["ROCIP"].Points.AddY(((RegionResults)ViewData["RegionResults"]).ROCIPSeverityA);
    Chart2.Series["ROCIP"].IsValueShownAsLabel = false;

    Chart2.Series["GC"].Points.AddY(((RegionResults)ViewData["RegionResults"]).GCSeverityB);
    Chart2.Series["GC"].IsValueShownAsLabel = false;

    Chart2.Series["OFPC"].Points.AddY(((RegionResults)ViewData["RegionResults"]).OFPCSeverityB);
    Chart2.Series["OFPC"].Points[1].AxisLabel = "B";
    Chart2.Series["OFPC"].IsValueShownAsLabel = false;

    Chart2.Series["ROCIP"].Points.AddY(((RegionResults)ViewData["RegionResults"]).ROCIPSeverityB);
    Chart2.Series["ROCIP"].IsValueShownAsLabel = false;

    Chart2.Series["GC"].Points.AddY(((RegionResults)ViewData["RegionResults"]).GCSeverityC);
    Chart2.Series["GC"].IsValueShownAsLabel = false;

    Chart2.Series["OFPC"].Points.AddY(((RegionResults)ViewData["RegionResults"]).OFPCSeverityC);
    Chart2.Series["OFPC"].Points[2].AxisLabel = "C";
    Chart2.Series["OFPC"].IsValueShownAsLabel = false;

    Chart2.Series["ROCIP"].Points.AddY(((RegionResults)ViewData["RegionResults"]).ROCIPSeverityC);
    Chart2.Series["ROCIP"].IsValueShownAsLabel = false;


    Chart2.Series["GC"].Points.AddY(((RegionResults)ViewData["RegionResults"]).GCSeverityD);
    Chart2.Series["GC"].IsValueShownAsLabel = false;

    Chart2.Series["OFPC"].Points.AddY(((RegionResults)ViewData["RegionResults"]).OFPCSeverityD);
    Chart2.Series["OFPC"].Points[3].AxisLabel = "D";
    Chart2.Series["OFPC"].IsValueShownAsLabel = false;

    Chart2.Series["ROCIP"].Points.AddY(((RegionResults)ViewData["RegionResults"]).ROCIPSeverityD);
    Chart2.Series["ROCIP"].IsValueShownAsLabel = false;

    Chart2.BorderSkin.SkinStyle = BorderSkinStyle.None;
    Chart2.BorderWidth = 0;

    Chart2.Legends.Add("Legend1");
    
        // show legend based on check box value
    Chart2.Legends["Legend1"].Enabled = true;

    // Render chart control
    Chart2.Page = this;
    var writer = new HtmlTextWriter(Page.Response.Output);
    Chart2.RenderControl(writer);

 %>
 <br />
 <% 
     var Chart3 = new System.Web.UI.DataVisualization.Charting.Chart
     {
         Width = 750,
         Height = 296,
         RenderType = RenderType.ImageTag,
         ImageLocation = "..\\..\\TempImages\\ChartPic_#SEQ(200,30)",
         Palette = ChartColorPalette.BrightPastel
     };
     Chart3.ChartAreas.Add("Area");
     Chart3.Series.Add("Series");
     Chart3.Series["Series"].ChartType = SeriesChartType.Pie;
     Chart3.Series["Series"]["PieLabelStyle"] = "Inside";
     Chart3.Series["Series"].Label = "#VALY";
     Chart3.Series["Series"].LegendText = "#VALX";

     // Display a Title
     Chart3.Titles.Add(string.Format("{0} Safety Deficiencies", ViewData["Region"]));
     // Add Data to Display
     Chart3.Series["Series"].Points.DataBindXY(((RegionResults)ViewData["RegionResults"]).DefeciencyTypes.Keys, ((RegionResults)ViewData["RegionResults"]).DefeciencyTypes.Values);

     // Call Out The Letter "D"
     

     // Display a Legend
     Chart3.Legends.Add(new Legend("Deficiencies"));
     Chart3.Legends["Deficiencies"].Title = "Deficiencies";

     Chart3.Series["Series"].Legend = "Deficiencies";
     Chart3.Page = this;
     writer = new HtmlTextWriter(Page.Response.Output);
     Chart3.RenderControl(writer);
 %>
 
 <h4><%=ViewData["Region"]%> Claims Reported - <%=((RegionResults)ViewData["RegionResults"]).Claims.Count%> Reported</h4>
 
    <table cellpadding="5" cellspacing="5" style="border-collapse:collapse" border="1">
        <tr>
            <td>#</td>
            <td>Coverage</td>
            <td>Date Of Loss</td>
            <td>Accident Narrative</td>
            <td>Site</td>
            <td>Project #</td>
            <td>Nature of Injury</td>
            
            
            
        </tr>
    <%
        var claims = ((RegionResults)ViewData["RegionResults"]).Claims;
        for (var i = 0; i < claims.Count; i++)
        {%>
        <tr>
            <td><%=i %></td>
            <td><%=claims[i].Coverage%></td>
            <td><%=claims[i].DateofLoss.ToShortDateString()%></td>
            <td><%=claims[i].AccidentNarrative%></td>
            <td><%=claims[i].SiteLevel1Name%></td>
            <td><%=claims[i].SiteLevel1%></td>
            <td><%=claims[i].NCCINatureofInjury%></td>
            
            
        </tr>
           
        <%}%>
        
    </table>
</asp:Content>
